home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 October / Chip Ekim 2003.iso / prog / code / contr / setup.exe / Disk1 / data1.cab / Configuration_En / Commands / Design Time Style Sheets.js < prev    next >
Encoding:
JavaScript  |  2003-07-18  |  4.1 KB  |  140 lines

  1. // Copyright 2001, 2002, 2003 Macromedia, Inc. All rights reserved.
  2. /***************** GLOBAL VARIABLES *****************/
  3.     
  4. var LIST_INCLUDED;
  5. var LIST_EXCLUDED;
  6.  
  7. var helpDoc = MM.HELP_cmdDesignTimeCSS;
  8.     
  9. /******************* API FUNCTIONS ******************/
  10.  
  11. function canAcceptCommand(){
  12.     // enable the menu item only if the document has been saved
  13.     var filePath = dreamweaver.getDocumentPath("document");
  14.     if (filePath)
  15.         return true;
  16.     else 
  17.         return false;
  18. }
  19.  
  20. function commandButtons(){
  21.   return new Array(MM.BTN_OK,"doCommand()",MM.BTN_Cancel,"window.close()",MM.BTN_Help,"displayHelp()");
  22. }
  23.  
  24.  
  25. /****************** LOCAL FUNCTIONS *****************/
  26.  
  27. function initUI(){
  28.     // initialize form fields
  29.     LIST_INCLUDED = new ListControl("included");
  30.     LIST_EXCLUDED = new ListControl("excluded");
  31.  
  32.     // Initialize from the design notes
  33.     var foundNotes = false;
  34.     var filePath = dreamweaver.getDocumentPath("document");
  35.     if (filePath) {
  36.         var metaFile;
  37.         metaFile = MMNotes.open(filePath, false);
  38.         if (metaFile) {
  39.             foundNotes = true;
  40.             
  41.             var includeString = MMNotes.get(metaFile, 'MM_css_include');
  42.             var includes = (includeString == "")?new Array(0):includeString.split(',');
  43.             for (var i=0; i < includes.length; i++){
  44.                 LIST_INCLUDED.append(includes[i],includes[i]);
  45.                 LIST_INCLUDED.setIndex(0);
  46.             }
  47.  
  48.             if (LIST_INCLUDED.getLen() > 0){
  49.                 LIST_INCLUDED.setIndex(0);
  50.             }
  51.  
  52.             var excludeString = MMNotes.get(metaFile, 'MM_css_exclude');
  53.             var excludes = (excludeString == "")?new Array(0):excludeString.split(',');
  54.             for (var i=0; i < excludes.length; i++){
  55.                 LIST_EXCLUDED.append(excludes[i],excludes[i]);
  56.             }
  57.  
  58.             if (LIST_EXCLUDED.getLen() > 0){
  59.                 LIST_EXCLUDED.setIndex(0);
  60.             }
  61.  
  62.  
  63.             MMNotes.close(metaFile);
  64.         }
  65.     }
  66. }
  67.  
  68. //*********************************************************************************
  69. // doCommand()
  70. //
  71. // Called when user clicks the OK button. Updates the design note with the lists
  72. // of included and excluded style sheets.
  73. //
  74. //*********************************************************************************
  75. function doCommand(){
  76.  
  77.     // if we were called from the UI (rather than arguments passed to 
  78.     // runCommand), then save includes and excludes text for next call to the command
  79.     var path = dw.getDocumentDOM().URL;
  80.     var metaFile;
  81.     metaFile = MMNotes.open(path, true);
  82.     if (metaFile) {
  83.         if (LIST_INCLUDED.getLen() > 0){
  84.             MMNotes.set(metaFile, 'MM_css_include', LIST_INCLUDED.getValue('all'));
  85.         }else{
  86.             MMNotes.set(metaFile, 'MM_css_include', "");
  87.         }
  88.         
  89.         if (LIST_EXCLUDED.getLen() > 0){
  90.             MMNotes.set(metaFile, 'MM_css_exclude', LIST_EXCLUDED.getValue('all'));
  91.         }else{
  92.             MMNotes.set(metaFile, 'MM_css_exclude', "");
  93.         }
  94.         
  95.         MMNotes.close(metaFile);
  96.     }
  97.  
  98.     // reload the document to fresh styles
  99.     dw.getDocumentDOM().refreshViews();
  100.  
  101.     window.close();
  102. }
  103.  
  104. //*********************************************************************************
  105. // addSS()
  106. //
  107. // Called when user clicks the + button. Opens a Browse dialog box that lets the
  108. // user choose a stylesheet; when the OK button in that dialog box is clicked,
  109. // the selected stylesheet is added to the list.
  110. //
  111. // arguments:
  112. // -    theList is the ListControl object that should be updated.
  113. //
  114. //*********************************************************************************
  115. function addSS(theList){
  116.     var newStyleSheet = dw.browseForFileURL();
  117.     if (!theList.pickValue(newStyleSheet)){
  118.         if (newStyleSheet != ""){
  119.             theList.append(newStyleSheet,newStyleSheet);
  120.         }
  121.     }else{
  122.         alert(MSG_ALREADY_THERE);
  123.     }
  124. }
  125.  
  126. //*********************************************************************************
  127. // removeSS()
  128. //
  129. // Called when user clicks the + button. Opens a Browse dialog box that lets the
  130. // user choose a stylesheet; when the OK button in that dialog box is clicked,
  131. // the selected stylesheet is added to the list.
  132. //
  133. // arguments:
  134. // -    theList is the ListControl object that should be updated.
  135. //
  136. //*********************************************************************************
  137. function removeSS(theList){
  138.     theList.del();
  139. }
  140.